import request from '@/utils/request'
export function getClients(data) {
  return request({
    url: '/clients',
    params: {
      _limit: data._limit,
      _start: data._start,
      name_contains: data.name_contains,
      agent_contains: data.searchParams
    }
  })
}
export function addClients(data) {
  return request({
    url: '/clients',
    method: 'post',
    data

  })
}
export function delClients(id) {
  return request({
    url: '/clients/' + id,
    method: 'delete'

  })
}
// 获取数了
export function countClients(data) {
  console.log(30, data)
  if (data) {
    if (data.id) {
      return request({
        url: '/clients/count',
        params: {
          agent: data.id,
          name_contains: data.name
        }
      })
    } else {
      return request({
        url: '/clients/count',
        params: {
          name_contains: data.name
        }
      })
    }
  } else {
    return request({
      url: '/clients/count'
    })
  }
}
export function getAgents() {
  return request({
    url: '/agents'
  })
}
// 编辑
export function getendio(id) {
  return request({
    url: '/clients/' + id
  })
}

export function postdio(data) {
  return request({
    url: `/clients/` + data.id,
    method: 'put',
    data
  })
}
